package io.lkt.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;

import io.lkt.common.validator.ValidatorUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.lkt.modules.sys.entity.BBusinessShareEntity;
import io.lkt.modules.sys.service.BBusinessShareService;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.R;



/**
 * 商学院课程分享表
 *
 * @author xss
 * @email dustwas@163.com
 * @date 2020-10-23 18:17:51
 */
@RestController
@RequestMapping("/sys/bbusinessshare")
public class BBusinessShareController {
    @Autowired
    private BBusinessShareService bBusinessShareService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("sys:bbusinessshare:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bBusinessShareService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
//    @RequiresPermissions("sys:bbusinessshare:info")
    public R info(@PathVariable("id") Integer id){
        BBusinessShareEntity bBusinessShare = bBusinessShareService.getById(id);

        return R.ok().put("bBusinessShare", bBusinessShare);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("sys:bbusinessshare:save")
    public R save(@RequestBody BBusinessShareEntity bBusinessShare){
        bBusinessShareService.save(bBusinessShare);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("sys:bbusinessshare:update")
    public R update(@RequestBody BBusinessShareEntity bBusinessShare){
        ValidatorUtils.validateEntity(bBusinessShare);
        bBusinessShareService.updateById(bBusinessShare);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("sys:bbusinessshare:delete")
    public R delete(@RequestBody Integer[] ids){
        bBusinessShareService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
